precision highp float;

uniform sampler2D u_src;
uniform vec2 u_screen_size;
uniform vec2 u_center;
uniform float u_radian;

varying vec2 v_uv;

const vec4 F = vec4(0.25, 0.5, 0.75, 1.0);
const vec4 W = vec4(0.14489292176612587, 0.12264921034103102, 0.09290249985875561, 0.06297020422491453);


void main () {
	vec2 rec_screen_size = 1.0 / u_screen_size;
	vec2 o = u_center;
	vec2 p = v_uv * u_screen_size;
	vec2 v = p - o;
	float r = length(v);
	float a0 = atan(v.y, v.x);
	float da = u_radian * 0.5;

	vec4 sum = texture2D(u_src, v_uv) * 0.153170327618346;
	for (int i = 0; i < 4; ++i) {
		float a1 = a0 + da * F[i];
		float a2 = a0 - da * F[i];
		vec2 v1 = vec2(cos(a1), sin(a1)) * r;
		vec2 v2 = vec2(cos(a2), sin(a2)) * r;
		vec2 uv1 = (o + v1) * rec_screen_size;
		vec2 uv2 = (o + v2) * rec_screen_size;
		sum += texture2D(u_src, uv1) * W[i];
		sum += texture2D(u_src, uv2) * W[i];
	}
	gl_FragColor = sum;
}